// StationAdd.cpp : implementation file
//

#include "stdafx.h"
#include "Measure.h"
#include "StationAdd.h"
#include "afxdialogex.h"


// CStationAdd dialog

IMPLEMENT_DYNAMIC(CStationAdd, CDialogEx)

CStationAdd::CStationAdd(CWnd* pParent, CMeasureSolution& solution,
CMeasureProject& project)
	: CDialogEx(CStationAdd::IDD, pParent)
  , solution_(solution)
  , project_(project)
  , name_(_T("station"))
  , camera_(_T(""))
  , model_(_T(""))
  , cmd_name_(_T(""))
  , find_model_(FALSE)
{

}

CStationAdd::~CStationAdd()
{
}

void CStationAdd::DoDataExchange(CDataExchange* pDX)
{
  CDialogEx::DoDataExchange(pDX);
  DDX_Text(pDX, IDC_STATION_NAME, name_);
  DDX_CBString(pDX, IDC_STATION_CAMERA, camera_);
  DDX_Control(pDX, IDC_STATION_CAMERA, wnd_camera_list_);
  DDX_Control(pDX, IDC_STATION_MODEL, wnd_model_list_);
  DDX_CBString(pDX, IDC_STATION_MODEL, model_);
  DDX_Control(pDX, IDC_STATION_CMD, wnd_cmd_list_);
  DDX_CBString(pDX, IDC_STATION_CMD, cmd_name_);
  DDX_Check(pDX, IDC_FIND_MODEL, find_model_);
  DDX_Control(pDX, IDC_FIND_MODEL, wnd_find_model_);
}


BEGIN_MESSAGE_MAP(CStationAdd, CDialogEx)
END_MESSAGE_MAP()


// CStationAdd message handlers


BOOL CStationAdd::OnInitDialog()
{
  CDialogEx::OnInitDialog();

  for (int index=0; index<solution_.cameras().num_cameras(); ++index) {
    wnd_camera_list_.AddString(solution_.cameras().camera(index)->Name().c_str());
  }

  if (solution_.cameras().num_cameras() > 0) {
    wnd_camera_list_.SetCurSel(0);
  }

  for (int index=0; index<project_.num_models(); ++index) {
    wnd_model_list_.AddString(project_.model(index)->Name().c_str());
  }

  if (project_.num_models() > 0) {
    wnd_model_list_.SetCurSel(0);
  }

  for (int index=0; index<project_.num_cmds(); ++index) {
    wnd_cmd_list_.AddString(project_.cmd(index)->Name().c_str());
  }

  if (project_.num_cmds() > 0) {
    wnd_cmd_list_.SetCurSel(0);
  }

  return TRUE;
}
